package com.btr.ivle.helper;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseWorkbin extends SQLiteOpenHelper {

	private String tableName=null;
	public final String ID="WorkbinID";
	public final String FolderName="WorkbinFolderName";
	public final String OpenDate="WorkbinOpenDate";
	public final String CloseDate="WorkbinCloseDate";
	public final String AllowUpload="WorkbinAllowUpload";
	public final String ParentID="WorkbinParentID";
	
	public final String FileName="WorkbinFileName";
	public final String FileSize="WorkbinFileSize";
	public final String FileType="WorkbinFileType";
	public final String isDownloaded="WorkbinisDownloaded";
	public final String UploadTime="WorkbinUploadTime";
	public final String isFile="WorkbinisFile";
	
	public final String WorkbinID="WorkbinWorkbinID";
	
	
	public DatabaseWorkbin(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
		this.tableName = name;
	}
	
	public void onCreate(SQLiteDatabase db) {
		  db.execSQL("CREATE TABLE IF NOT EXISTS "+ tableName +" ( "+ ID + " TEXT PRIMARY KEY , "+
				  FolderName + " TEXT, " + OpenDate + " TEXT, " + CloseDate + " TEXT, " + AllowUpload
				  + " INTEGER, " + FileName + " TEXT, " + FileSize + " INTEGER, " + FileType + " TEXT,"
				  + isDownloaded + " INTEGER, " + ParentID + " TEXT, " + 
				  UploadTime + " TEXT, " + isFile + " INTEGER, " + WorkbinID + " TEXT)"
				  );
	}
	
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		  db.execSQL("DROP TABLE IF EXISTS "+ tableName);
		  onCreate(db);
		 }
}
